package Presentation;

import Metier.Controleurs.GestionVueSynthetique;
import java.awt.BorderLayout;
import java.util.ResourceBundle;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class OngletVueSynth extends Onglet {

    /**
     * Attributs
     */
    private final GestionVueSynthetique gVue;
    private javax.swing.JScrollPane scrollTblGeneral;
    private javax.swing.JTable tblGeneral;
    private final ResourceBundle configBundle;
    
    public OngletVueSynth(FenetrePrincipale fp) {
        super(fp);
        this.gVue = new GestionVueSynthetique(this);
        this.configBundle = ResourceBundle.getBundle("ressources/VueSynthetique/Vue", fp.getLocale());

        initComponents();
    }
    
    private void initComponents() {
        // JTable des stocks, contenu importé depuis GestionVueSynthetique
        this.tblGeneral = new JTable(this.gVue.getContenuTableauGeneral()){
            @Override
            public boolean isCellEditable(int row, int column){
                return false;
            }
        };
        this.tblGeneral.setRowHeight(20);
        DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
        centerRenderer.setHorizontalAlignment(JLabel.CENTER );
        tblGeneral.setDefaultRenderer(Object.class, centerRenderer);
        
        this.scrollTblGeneral = new JScrollPane(this.tblGeneral);
        this.add(this.scrollTblGeneral, BorderLayout.CENTER);
    }

    @Override
    public void rafraichir() {
        this.tblGeneral.removeAll();
        this.tblGeneral.setModel(gVue.getContenuTableauGeneral());
    }

    @Override
    public void help() {
        JOptionPane.showMessageDialog(this.getFP(),
                configBundle.getString("vue.txtaide"),
                configBundle.getString("vue.aide"),
                JOptionPane.INFORMATION_MESSAGE);
    }
}
